<template>
  <div class="search-item-component">
    <label :class="['search-title', { required: required }]" v-if="label || $slots.label">
      <slot name="label">{{ label }}</slot>
    </label>
    <div class="search-content">
      <slot>{{ content }}</slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'search-item',
  props: {
    label: {
      type: String,
      default: ''
    },
    content: {
      type: String,
      default: ''
    },
    required: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style lang="scss" scoped>
.search-item-component {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  .search-title {
    flex: 0 0 auto;
    padding: 0px 10px 0px 0;
    line-height: 32px;
    white-space: nowrap;

    &.required::before {
      content: '*';
      color: #f56c6c;
      margin-right: 4px;
    }
  }

  .search-content {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 42px;
    line-height: 32px;
    padding: 5px 0;

    > div:not(:first-child) {
      margin-left: 10px;
    }
  }
}
</style>
